<?php

use yii\helpers\Html;
use yii\helpers\Url;
use yii\grid\GridView;

/**
* @var yii\web\View $this
* @var yii\data\ActiveDataProvider $dataProvider
    * @var yiike\store\model\StoreSearch $searchModel
*/

$this->title = Yii::t('models', '商家管理');
$this->params['breadcrumbs'][] = $this->title;

if (isset($actionColumnTemplates)) {
$actionColumnTemplate = implode(' ', $actionColumnTemplates);
    $actionColumnTemplateString = $actionColumnTemplate;
} else {
Yii::$app->view->params['pageButtons'] = Html::a('<span class="glyphicon glyphicon-plus"></span> ' . 'New', ['create'], ['class' => 'btn btn-success']);
    $actionColumnTemplateString = " {update} {delete}{goods}{order}";
}
$actionColumnTemplateString = '<div class="action-buttons">'.$actionColumnTemplateString.'</div>';
?>
<div class="box box-info giiant-crud store-index">
    <div class="box-header with-border">
        <div class="box-title">
            <?= Yii::t('models', '商家管理') ?>
        </div>
    </div>
    <div class="box-body">
    <?php
//             echo $this->render('_search', ['model' =>$searchModel]);
        ?>

    
    <?php \yii\widgets\Pjax::begin(['id'=>'pjax-main', 'enableReplaceState'=> false, 'linkSelector'=>'#pjax-main ul.pagination a, th a', 'clientOptions' => ['pjax:success'=>'function(){alert("yo")}']]) ?>


    <div class="clearfix crud-navigation">
        <div class="pull-left">
            <!--<?= Html::a('<span class="glyphicon glyphicon-plus"></span> ' . 'New', ['create'], ['class' => 'btn btn-success']) ?>-->
        </div>

        <div class="pull-right">

                                                                                
           <!-- <?=
            \yii\bootstrap\ButtonDropdown::widget(
            [
            'id' => 'giiant-relations',
            'encodeLabel' => false,
            'label' => '<span class="glyphicon glyphicon-paperclip"></span> ' . 'Relations',
            'dropdown' => [
            'options' => [
            'class' => 'dropdown-menu-right'
            ],
            'encodeLabels' => false,
            'items' => [
            [
                'url' => ['ttyc-category/index'],
                'label' => '<i class="glyphicon glyphicon-arrow-left"></i> ' . Yii::t('models', 'Ttyc Category'),
            ],
                                [
                'url' => ['ttyc-category/index'],
                'label' => '<i class="glyphicon glyphicon-arrow-left"></i> ' . Yii::t('models', 'Ttyc Category'),
            ],
                    
]
            ],
            'options' => [
            'class' => 'btn-default'
            ]
            ]
            );
            ?>
            -->
        </div>
    </div>

    <hr />

    <div class="table-responsive">
        <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'pager' => [
        'class' => yii\widgets\LinkPager::className(),
        'firstPageLabel' => '首页',
        'lastPageLabel' => '末页',
        ],
                    'filterModel' => $searchModel,
                'tableOptions' => ['class' => 'table table-striped table-bordered table-hover'],
        'headerRowOptions' => ['class'=>'x'],
        'columns' => [
                [
            'class' => 'yii\grid\ActionColumn',
            'template' => $actionColumnTemplateString,
            'buttons' => [
                'view' => function ($url, $model, $key) {
                    $options = [
                        'title' => Yii::t('cruds', 'View'),
                        'aria-label' => Yii::t('cruds', 'View'),
                        'data-pjax' => '0',
                    ];
                    return Html::a('<span class="glyphicon glyphicon-file"></span>', $url, $options);
                },
                'goods'=>function ($url,$model,$key){
                    $options = [
                        'title' => Yii::t('cruds', '商品管理'),
                        'aria-label' => Yii::t('cruds', '商品管理'),
                        'data-pjax' => '0',
                        'class'=>'btn btn-info btn-xs',
                        'style'=>'margin-left:10px'
                    ];
                    $url = Url::toRoute(['/goods/goods/store-goods','store_id'=>$model->id]);
                    return Html::a('<span style="margin-left:5px;"></span>'.'商品管理', $url, $options);
                },
                'order'=>function ($url,$model,$key){
                    $options = [
                        'title' => Yii::t('cruds', '订单管理'),
                        'aria-label' => Yii::t('cruds', '订单管理'),
                        'data-pjax' => '0',
                        'class'=>'btn btn-success btn-xs',
                        'style'=>'margin-left:10px'
                    ];
                    $url = Url::toRoute(['/order/order-store/store-order','store_id'=>$model->id]);
                    return Html::a('<span style="margin-left:5px;"></span>'.'订单管理', $url, $options);
                },
            ],
            'urlCreator' => function($action, $model, $key, $index) {
                // using the column name as key, not mapping to 'id' like the standard generator
                $params = is_array($key) ? $key : [$model->primaryKey()[0] => (string) $key];
                $params[0] = \Yii::$app->controller->id ? \Yii::$app->controller->id . '/' . $action : $action;
                return Url::toRoute($params);
            },
            'contentOptions' => ['nowrap'=>'nowrap']
        ],
            'id',
            ['label'=>'logo','format'=>'raw','value'=>function($model){
                return Html::img(Yii::getAlias('@storageUrl/source').'/'.$model->logo,['alt' => 'logo','width' => 80]);
            }],
            'title',
            [
                'label'=>'营业时间',
                'format'=>'raw',
                'content'=>function($model){
                    return $model->starttime.'到'.$model->endtime;
                }
            ],
            'username',
            'tel',

            [
                'label'=>'属性',
                // 'format'=>'raw',
                'attribute'=>'checked',
                'content'=>function($model){
                    if($model->checked==1){
                        return Html::label('已审核','',['class'=>'label label-success']);
                    }else{
                        return Html::label('未审核','',['class'=>'label label-warning']);
                    }
                },
                'filter' => [0=>'未审核',1=>'已审核'],//重点在这里，传入一个数组，会下拉框显示
            ],
            'dateline:datetime:提交时间',
			/*'isfirst',*/
			/*'top',*/
			/*'mode',*/
			/*'checked',*/
			/*'status',*/
			/*'displayorder',*/
			/*'isvip',*/
			/*'vip_start',*/
			/*'vip_end',*/
			/*'max_sub',*/
			/*'maker_id',*/
			/*'company_id',*/
			/*'commission_rate',*/
			/*'service_rate',*/
			/*'sold',*/
			/*'address',*/
			/*'discounts',*/
			/*'consume',*/
			/*'description:ntext',*/
			/*'images:ntext',*/
			/*'lat',*/
			/*'lng',*/
			/*'shop_quan_rate',*/
			/*'combo',*/
			/*'wx_mchid',*/
			/*'alipay_mchid',*/
			/*'username',*/
			/*'tel',*/
			/*'bank_account',*/
			/*'title',*/
			/*'from_user',*/
			/*'bank',*/
			/*'payee',*/
			/*'logo',*/
			/*'services',*/
			/*'place',*/
			/*'hours',*/
			/*'businesslicense',*/
			/*'starttime',*/
			/*'endtime',*/
			/*'location_p',*/
			/*'location_c',*/
			/*'location_a',*/
			/*'bank_sub',*/
        ],
        ]); ?>
    </div>
        <?php \yii\widgets\Pjax::end() ?>
    </div>
</div>




